firmware-utils: tplink-safeloader: refactor meta-partition generation
authorSander Vanheule <[email protected]>
Wed, 5 Aug 2020 18:49:44 +0000 (20:49 +0200)
committerAlexander Couzens <[email protected]>
Mon, 7 Dec 2020 00:55:28 +0000 (01:55 +0100)
commitfc742610a34dc98cb6186487965c1514b432099a
tree99a47f3088e28aae2d09c9e7c7c6a1c689005747
parent0f1cffbf6666f9b3e999785da57851fcab53a79d
firmware-utils: tplink-safeloader: refactor meta-partition generation

TP-Link safeloader firmware images contain a number of (small)
partitions with information about the device. These consist of:
* The data length as a 32-bit integer
* A 32-bit zero padding
* The partition data, with its length set in the first field

The OpenWrt factory image partitions that follow this structure are
soft-version, support-list, and extra-para. Refactor the code to put all
common logic into one allocation call, and let the rest of the data be
filled in by the original functions.

Due to the extra-para changes, this patch results in factory images that
change by 2 bytes (not counting the checksum) for three devices:
* ARCHER-A7-V5
* ARCHER-C7-V4
* ARCHER-C7-V5

These were the devices where the extra-para blob didn't match the common
format. The hardcoded data also didn't correspond to TP-Link's (recent)
upgrade images, which actually matches the meta-partition format.

A padding byte is also added to the extra-para partition for EAP245-V3.

Signed-off-by: Sander Vanheule <[email protected]>
Makefile
src/tplink-safeloader.c